import React from 'react'
import { Layout } from 'antd'
import layoutStyle from '../../home/layout.less'
import HeaderTool from '../../home/header/HeaderTool'
import { Content } from 'antd/es/layout/layout'
import ReactDom from 'react-dom'
import indexStyle from '../index.less'
import BasicContent from '../BasicContent/BasicContent'
import LoginModule from '../components/LoginModule'

class BasicLayout extends React.PureComponent {
  constructor (props) {
    super(props)
    this.state = {
      // padding: 5,
      headerHeight: 48,
      bottomHeight: 90
    }
  }

  componentDidMount () {
    this.resizeWindowUI()
  }

  resizeWindowUI = () => {
    // 取屏幕宽高
    // body宽高
    const { bottomHeight, headerHeight } = this.state
    const parentDom = ReactDom.findDOMNode(this).parentNode.parentNode
    let width = parentDom.offsetWidth
    let height = parentDom.offsetHeight
    const contentHeight = height - headerHeight - bottomHeight
    this.setState({
      width,
      height,
      contentHeight
    })
  }

  render () {
    const { headerHeight, height } = this.state
    return (
      <Layout style={{ height }}>
        <header className={layoutStyle.header}>
          {/*<HeaderTool height={headerHeight}/>*/}
          <HeaderTool height={headerHeight}/>
        </header>
        <Content className={indexStyle.content}>
          <BasicContent/>
        </Content>
        <LoginModule/>
      </Layout>
    )
  }
}

export default BasicLayout
